'use strict'

class guanzhu{
  constructor(){
    this.param = '/'
  }

  async post(c){
    let a = c.service.fun;
    let {user_id,followed_id} = JSON.parse(c.body);
    let f_id = followed_id;
    c.setHeader('content-type', 'text/html; charset=utf-8')
    console.log(user_id);
    console.log(f_id);
    let data1 = await a.sel('follow_list',{'follow_id':`${user_id}`},['followed_id'],c.service.pool);
   // console.log(data1.rows[0]);
    let data = data1.rows.some(item=>{
      return f_id == item.followed_id
    })
    if(data){
      a.del('follow_list',{'follow_id':`${user_id}`,'followed_id':`${f_id}`},c.service.pool);
      c.send('no')
    }else{
      a.add('follow_list',{'follow_id':`${user_id}`,'followed_id':`${f_id}`},c.service.pool);
      c.send('ok')
    }
  }
}
module.exports = guanzhu;
